Hi to all.
I made my own theme, and now i want to show the total number of the images i have in different albums. I'd like to have it on the index.php page of my template.
I noticed that if i use the getTotalImagesIn function without parameters it didn't work.
I'm pretty ignorant in php
I tried this but it dont work
<php? $number = getTotalImagesIn(); if ($number > 1) $number .= " photos"; else $number .=" photo"; echo$number; ?>
Any help???
Thanks in advance
Comments
It seems to work on my album.php page instead.
I wonder why.. Missing parameters?
If u want to take a look my ZP gallery is in filmposter.netsons.org/zenphoto/index.php
Please take a look at our functions guide, too.
If you mean the total number of all images in all albums? There is no function for that if I recall correctly. Use something like this:
`<?php $photosArray = query_single_row("SELECT count(*) FROM ".prefix('images')); $photosNumber = array_shift($photosArray); echo $photosNumber ?>`(taken from stopdesign theme).
Probably worth considering a standard function for that.
`
224 /**
225 * Returns the number of images from a database SELECT count(*)
226 * Ideally one should call garbageCollect() before to make sure the database is current.
227 * @return int
228 */
229 function getNumImages() {
230 $result = query_single_row("SELECT count(*) FROM ".prefix('images'));
231 return array_shift($result);
232 }
`
If u look at my pages, u'll find that i did 26 albums (A, B, C, etc.) to make a gallery browsable by the starting letter of an image's name. So a function that returns total numbers of images in all allbums would be nice for me.
Thanks a lot and please excuse my english, I'm from Italy
I'm looking for a function like getNumImages() but I would like to exclude images from unpublished albums, is it possible ?
in my template, I use this code
[code]
<?php $photosArray = query_single_row("SELECT count(*) FROM ".prefix('images')); $photosNumber = array_shift($photosArray); echo $photosNumber ?>
[/code]
I have a lot of unpublished albums (images and docs used in a CMS, files are shared between the CMS and ZP). Around 60% of images are in unpublished albums (± 2500 images)
thanks
ps: sorry for my english, I'm french
Actually `getNumImages()` gets only the image count of the current selected album.
You could try instead using the gallery class method `$_zp_gallery->getNumImages()` that gets the count of all images of your gallery.
I've tried but the count is the same with `$_zp_gallery->getNumImages()`
I tried to see with orther browsers, clean all cookies, history, etc... but I have the total of images (published and unpublished albums)
I don't know if the problem is coming from my computer or not, you can see my gallery (still under construction) here :
http://www.bilin-village.org/photos/
- a happy new user
Hi macalter, thanks for your good words. That was a site I did a lot time ago. I programmed to translate it into english but i never did it...
To make subtitles to image thumbnails I symply made a div beneath the div with the thumbnail with <?php printImageTitle();?> in it. A little adjustament by CSS and it worked very fine
I've updated my ZP install with the latest nighly version (5/06) and tried `$gallery->getNumImages(true)` but the count is still the total of all images (I'm not logged on the gallery)... must I uncheck "visible" for images in unpublished albums ?
Gallery (http://www.bilin-village.org/photos/) :
- albums : 18 - 1806 images
- total images : 4752
Admin Tool (Gallery Stats)
- 4752 images (2884 unpublished)
- 39 albums (18 unpublished)
Admin is using the new calls to get this information, so if it shows the data, the function is working.
Have you initialized your `$gallery` variable? Perhaps you should be using `$_zp_gallery`
I've tried `$_zp_gallery->getNumImages(true)`, it's almost perfect (some images should not be counted)
it will be long and difficult for me to explain the problem in english, I've made a screenshot with the "description" of the problem, I think it's linked with subalbums
http://img527.imageshack.us/img527/1010/image2hz6.png
I've tried before and did it again when I read your message but nothing changes... it's not so important, I think images counted are in subalbums even if they are not published
I'll deal with it because I choose to share the same folder for ZP albums and a CMS, and these subalbums contain images for the CSS of the CMS
for the moment, my problem is to understand how does ZP works when I add new images on existing albums via FTP...
I've searched and read subjects on the forum and don't understand yet (english is not my first language, it doesn't help)
I've checked this :
- safe_mode is OFF
- mod_rewrite is ON
- cache folder + every folder in cache folder have 777 permission
- each folder in "album folder" has 755 permission
- each image in album folder has 644 permission
- thumbnails created in cache folders have 666 permission
when I send images via FTP :
- count on the gallery is OK (new images are in)
- if I look the gallery, new images are not there, it's normal because if I look in the database new images are not there (no new entry)
I'm trying to understand when entries are created in the database :
1) wait half an hour to see if new images will be created in the database > no
2) refresh the database > no
3) I try "pre-cache images" (without checking "clear") on the admin, after 40 minutes, Safari stopped loading the page (5317 errors - timeout mention in acitivty window) > but it works, new images are in the DB
yesterday, I've tried something else : edit the album on the admin, it creates also entries in the DB for new images but loading the "album page" is too slow for galeries over 400 images (more than 5 minutes for 400 images)
using "pre-cache" or "edit the album" on the admin tool are too slowly to update "big gallery"... for me, it's better to use phpMyAdmin to update informations (title, etc) for saving time...
what should I do ?
how does it works when images are uploaded by FTP ?
sorry for the "off-topic" (and maybe redundant subject) but I'm trying to understand
I find a way to use "pre-cache" very quickly, in `cache-images.php`, I comment this :
`echo ' | ' . "n";`
my solution is :
- pre-cache, everytime I send new pics
- use phpmyadmin to update data in "big galleries", otherwise the admin is cool for "small galleries"
sorry if I bother you... I'll be a nice quiet girl now...
There actually should be only images/albums that are to be used for zenphoto in the albums folder. Confusion is preprepared if you put css images in there. I would recommend to keep images for "styling" separate from the "content" ones.
- share my "media folder" (didn't want to duplicate images)
- using same image in a ZP gallery or, for example, in an article or a slideshow included in an article
- publish latest images on the homepage (CMS)
- publish albums on a special page (CMS)
this folder contains docs, images, etc for 3 websites (same website in 3 languages) and also galleries... images I use for ZP galleries are in folders untitled "alb_" and contain only images (folders don't start by the prefix "alb_" are unpublished precisely to avoid confusion)
EDIT: I see you use Plume CMS.